package academic.emailClient.control.listeners;

import java.awt.event.ItemEvent;
import java.awt.event.ItemListener;
import java.util.ArrayList;
import academic.emailClient.model.EmailClientModel;
import academic.emailClient.model.entities.Meeting;
import academic.emailClient.view.EmailClientViewInterface;

public class ModifyMeetingsComboBoxChangedListener implements ItemListener {
	EmailClientViewInterface view;
	EmailClientModel model;
	
	/**
	 * ModifyMeetingsComboBoxChangedListener Constructor
	 * @throws Exception 
	 */
	
	public ModifyMeetingsComboBoxChangedListener(EmailClientViewInterface view, EmailClientModel model) throws Exception{
		this.model = model;
		this.view = view;		
	}
	
	/**
	 * Handle Modify Meetings ComboBox Changed event
	 */
	@Override
	public void itemStateChanged(ItemEvent e) {
		 if (e.getStateChange() == ItemEvent.SELECTED) {
			 ArrayList<Meeting> meetings = new ArrayList<Meeting>(model.getMeetings().values());				
			 view.loadModifyMeetingAreas(meetings);	
		 }
	}
}
